﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core.Interfaces;
using Cofe.Core.Property;

namespace Cofe.Core.Implements
{
    [Export(typeof(ICofeService))]
    [ServicePriority(ServicePriorityAttribute.DefaultPriority_COFE)]
    public class VolumeRegistrarGetRootBehavior : IVolumeRegistrarGetRootBehavior
    {
        public IEnumerable<IPropertyHost> GetRootPropertyHosts()
        {
            return CofeServices.VolumeRegistrar.LookupVolumes(v => true, false).ToArray()
                .SelectMany(v => v.DirectoryLister.GetRootPropertyProviders())
           .Select(pp => CofeServices.EntryConstructor.ConstructPropertyHost(pp)).ToList();
        }

        public EntryConstructionFlags[] SupportedConstructionFlags
        {
            get
            {
                return new[] {
                    EntryConstructionFlags.DefaultWithLookup,
                    EntryConstructionFlags.Default,
                    EntryConstructionFlags.DefaultWithoutCache,
                    EntryConstructionFlags.DefaultWithoutCacheWithLookup
                };
            }
        }
    }
}
